package com.puyuba.puyuba;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.alibaba.android.arouter.launcher.ARouter;
import com.easefun.polyv.livecommon.module.config.PLVLiveSDKConfig;
import com.easefun.polyv.livescenes.config.PolyvLiveSDKClient;
import com.easefun.polyvsdk.PolyvSDKClient;
import com.hjq.toast.ToastUtils;
import com.pyb.java.cache.SPHelper;
import com.pyb.java.commonutil.utils.AppUtils;
import com.pyb.java.commonutil.FastJsonParse;
import com.pyb.java.commonutil.JsonHelper;

import androidx.multidex.MultiDex;

public class MultiDexApplication extends Application {

    private static final String TAG = MultiDexApplication.class.getSimpleName();
    private static Application application;
    private static Activity current;
    public static Context sContext;

    public MultiDexApplication() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        sContext = this;
        PLVLiveSDKConfig.init(
                new PLVLiveSDKConfig.Parameter(this)//sdk初始化所需参数
                        .isOpenDebugLog(true)//是否打开调试日志
                        .isEnableHttpDns(false)//是否使用httpdns
        );
        PolyvLiveSDKClient.getInstance().setAppIdSecret("583fc2b1f4","eijrru3it3","9893f17fc53e4b3b9beaf72bfcb3f9c6");
        PolyvSDKClient sdkClient = PolyvSDKClient.getInstance();
//        sdkClient.settingsWithUserid("583fc2b1f4", "pTHhyNcRRd", "9WJCQuJkdX-G1owtSRG0g-70yaJKqby7", "LCO32UUnpANrqb2-tHRdLl6Mj8RiLGCS");
        //设置SDK加密串
//        sdkClient.settingsWithConfigString("SzFF2wFhyezIBbXC2STQhgSUWDuYPUuu2oKztdgFyS+p3aZ1E28NWkhNo0MiQJO5h6gpjJZWVUnQfjQF5ulKfP3HsYyt/eaat6uagVtkAXvUK1LtJzbrfKlhP9oE49Q75/AhbQQ40Y225YJJ0f6G7Q==", "VXtlHmwfS2oYm0CZ", "2u9gDPKdX6GyQJKU");
        sdkClient.settingsWithAppId("eijrru3it3","pTHhyNcRRd","583fc2b1f4");
        sdkClient.initSetting(getApplicationContext());
        //设置学员唯一标识
        sdkClient.setViewerId("00001");
        AppUtils.getInstance().setApp(this);
        JsonHelper.init(new FastJsonParse());
        SPHelper.init(this);
        ToastUtils.init(this);
        if (BuildConfig.DEBUG) {
            ARouter.openDebug();
            ARouter.openLog();
        }
        ARouter.init(this);

    }

    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
//        MultiDex.install(this);
    }

    public static Application getApplication() {
        return application;
    }

    public static Activity getCurrentActivity() {
        return current;
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        ARouter.getInstance().destroy();
    }
}
